package com.bookmarket.service.impl;

import com.bookmarket.dao.LJproductListMapper;
import com.bookmarket.entity.*;
import com.bookmarket.service.IProductListService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service("/iProductListService")
public class ProductListImpl implements IProductListService{


        @Resource
        private LJproductListMapper lJproductListMapper;


        //查询出版社
        public List<Book> selectByPublish(){
            return lJproductListMapper.selectByPublish();
        }
        //查询作者
        public List<Book> selectByauthor(){
            return lJproductListMapper.selectByauthor();
        }
        //分页查书籍
        public Page getPage(int pageNum,int pageSize,Book book) {
            Page page = PageHelper.startPage(pageNum, pageSize);
            List list = lJproductListMapper.selectByAll(book);
            return page;
        }
        //排序
        public Page OrderBy(int pageNum,int pageSize,Map map){
            Page page = PageHelper.startPage(pageNum, pageSize);
            List list = lJproductListMapper.selectOrderBy(map);
            return page;
        }
        /***********************************************************************/
        //根据小类型分页查询
        public Page selectByStype(int pageNum,int pageSize,String [] stypeid){
            Page page=PageHelper.startPage(pageNum,pageSize);
            List list=lJproductListMapper.selectByStype(stypeid);
            return page;
        }
        //查询大类型对应的小类型
        public List<Stype> selectByBtypeId(int id){
            return lJproductListMapper.selectByBtypeId(id);
        }
        //什么都不添加查询所有
        public Page selectBook(int pageNum,int pageSize){
            Page page=PageHelper.startPage(pageNum,pageSize);
            List list=lJproductListMapper.selectBook();
            return page;
        }
        /*******************************************************************************/
        //评论
        public int Count(int book_id){
            return lJproductListMapper.Count(book_id);
        }
        //加入购物车
        public Boolean insertShop(Shop shop){
            return lJproductListMapper.insertShop(shop);
        }
        //根据id查询book
        public Book selectById(int id){
            return lJproductListMapper.selectById(id);
        }
        //根据name查询tb_custom
        public Custom selectByName(String name){
            return lJproductListMapper.selectByName(name);
        }
        //热门浏览
        public List<Book> selectByclickBook(){
            return lJproductListMapper.selectByclickBook();
        }
        /*
        @Override
        public List<Book> aaa(int status,Book book) {
            Map map = new HashMap();
            map.put("status",status);
            map.put("book",book);
            return lJproductListMapper.aaa(map);

        }*/
        //get/set
        public LJproductListMapper getlJproductListMapper() {
            return lJproductListMapper;
        }

        public void setlJproductListMapper(LJproductListMapper lJproductListMapper) {
            this.lJproductListMapper = lJproductListMapper;
        }
}
